<script type="text/javascript">
	function hilangkan_pilihan(){
		document.getElementById("tab_pil").style.display="none";
	}
	function munculkan_pilihan(){
		document.getElementById("tab_pil").style.display="";
	}


	var idrow_1 = <?php echo count($pilihan) ?>;

	function tambah_1(){
		var x=document.getElementById('tab_pil').insertRow(idrow_1);
		var td1=x.insertCell(0);
		td1.innerHTML="<input type='text' name='jawaban[]' id='pilihan' />";
		idrow_1++;
	}

	function hapus_1(){
		if(idrow_1>0){
			var x=document.getElementById('tab_pil').deleteRow(idrow_1-1);
			idrow_1--;
		}
	}
</script>
<form action="<?php
if ($mode!='edit')
echo base_url().'admin/poling_con/simpan_tambah_pertanyaan';
else
    echo base_url().'admin/poling_con/simpan_edit_pertanyaan/'.$id;
?>" method="post">
    nama pertanyaan <input type="text" name="nama" value="<?php
                            echo $nama;?>" />
    tipe pertanyaan <select name="tipe">
    <option value="essay" onclick="hilangkan_pilihan()" <?php if($tipe=='essay') echo "selected"; ?>>essay</option>
    <option value="multi" onclick="munculkan_pilihan()" <?php if($tipe=='multi') echo "selected"; ?>>multi</option>
    <option value="single" onclick="munculkan_pilihan()" <?php if($tipe=='single') echo "selected"; ?>>single</option>
                    </select>

<br />

    <table id="tab_pil" width="403" border="0" <?php if($tipe == 'essay' || $tipe == null) echo 'style="display: none"'; ?>>

			<?php if($pilihan!=null) { 
                            for ($i=0;$i<count($pilihan);$i++)
                            {
                            ?>

                        <tr><td><input type='text' name='jawaban[]' id='pilihan' value="<?php echo $pilihan[$i]['ISI_PILIHAN'] ?>" /></td></tr>
                    <?php 
                            }
                    } ?>
                <tr><td><input type="button" value="tambah" onclick="tambah_1()" />&nbsp;<input type="button" value="kurang" onclick="hapus_1()" /></td></tr>
                </table>

    <input type="submit" value="simpan" />
</form>
